﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace CSequence
{
    class CSqlString
    {
        public static string GetConnectionType(string sConnString)
        {
            //Example Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\Sapiens\Sequence\Sequence.xls;Extended Properties="Excel 8.0; HDR = YES;"
            string sRet = "ORA";
            if (sConnString.IndexOf("Microsoft.Jet.") > 0)
                sRet = "XLS";
            else if (sConnString.IndexOf("oracle") > 0)
                sRet = "ORA";
            else if (sConnString.IndexOf("Microsoft.ACE") > 0)
                sRet = "ACC";
            else
                sRet = "MSS";
            return sRet;
        }

        public static string GetDeleteProcess(string sDBMS,string sProcessId, string sId, string sToSql)
        {
            string sSql = "";
            switch (sDBMS)
            {
                case "ACC":
                case "MSS":
                case "ORA":
                    sSql = "Begin \r\n";
                    sSql += "delete from T_API_QD_PROCESS_STEP where PROCESS_ID=" + sProcessId + " and ID=" + sId + ";\r\n";
                    sSql += "delete from T_API_QD_PROCESS_STEP_PARAMS where PROCESS_ID=" + sProcessId + " and STEP_ID=" + sId + ";\r\n";
                    sSql += sToSql;
                    sSql += "end;";
                    break;
                case "XLS":
                    break;
            }
            return sSql;           
        }
    }
}
